package com.deyuanyun.pic.pipe.controller.vo.merge;

import com.deyuanyun.pic.common.util.ObjectUtil;
import com.deyuanyun.pic.common.util.format.NumberFormat;
import com.deyuanyun.pic.pipe.controller.vo.BaseVO;
import com.deyuanyun.pic.pipe.controller.vo.BaseVOUtil;
import com.deyuanyun.pic.pipe.domain.AdjunctLine;
import com.deyuanyun.pic.pipe.domain.AdjunctPoint;
import com.deyuanyun.pic.settings.support.biz.CodeUtil;
import com.deyuanyun.pic.settings.support.biz.PipeLineUtil;
import com.github.pagehelper.Page;

/**
 * 附属物信息表
 */
public class AdjunctVo extends BaseVO<AdjunctLine> {

    // 管道名称
    private String pipeLineName;
    // 统一编号
    private String code;
    // 附属物编号
    private String customNumber;
    // 附属物类型
    private String appurtenanceType;
    // 附属物状态
    private String appurtenanceStatus;
    // 起点绝对距离(m)
    private String fromMileage;
    // 起点相对最近参考点
    private String fromReference;
    // 起点相对最近参考点距离(m)
    private String fromReferenceDistance;
    // 终点绝对距离(m)
    private String toMileage;
    // 终点相对最近参考点
    private String toReference;
    // 终点相对最近参考点距离(m)
    private String toReferenceDistance;
    // 链接计算结果表
    private String gisId;

    public String getPipeLineName() {
        return pipeLineName;
    }

    public void setPipeLineName(String pipeLineName) {
        this.pipeLineName = pipeLineName;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getCustomNumber() {
        return customNumber;
    }

    public void setCustomNumber(String customNumber) {
        this.customNumber = customNumber;
    }

    public String getAppurtenanceType() {
        return appurtenanceType;
    }

    public void setAppurtenanceType(String appurtenanceType) {
        this.appurtenanceType = appurtenanceType;
    }

    public String getAppurtenanceStatus() {
        return appurtenanceStatus;
    }

    public void setAppurtenanceStatus(String appurtenanceStatus) {
        this.appurtenanceStatus = appurtenanceStatus;
    }

    public String getFromMileage() {
        return fromMileage;
    }

    public void setFromMileage(String fromMileage) {
        this.fromMileage = fromMileage;
    }

    public String getFromReference() {
        return fromReference;
    }

    public void setFromReference(String fromReference) {
        this.fromReference = fromReference;
    }

    public String getFromReferenceDistance() {
        return fromReferenceDistance;
    }

    public void setFromReferenceDistance(String fromReferenceDistance) {
        this.fromReferenceDistance = fromReferenceDistance;
    }

    public String getToMileage() {
        return toMileage;
    }

    public void setToMileage(String toMileage) {
        this.toMileage = toMileage;
    }

    public String getToReference() {
        return toReference;
    }

    public void setToReference(String toReference) {
        this.toReference = toReference;
    }

    public String getToReferenceDistance() {
        return toReferenceDistance;
    }

    public void setToReferenceDistance(String toReferenceDistance) {
        this.toReferenceDistance = toReferenceDistance;
    }

    public String getGisId() {
        return gisId;
    }

    public void setGisId(String gisId) {
        this.gisId = gisId;
    }

    @Override
    public void fromDomain(AdjunctLine domain) {

        if (ObjectUtil.isEmptyAll(domain)) {
            return;
        }

        // 管道ID
        this.pipeLineName = PipeLineUtil.getPipeLineName(domain.getPipeLineId());
        // 统一编号
        this.code = domain.getCode();
        // 附属物编号(自定义编号)
        this.customNumber = domain.getCustomNumber();
        // 附属物类型
        this.appurtenanceType = CodeUtil.getName(domain.getAppurtenanceType());
        // 附属物状态
        this.appurtenanceStatus = CodeUtil.getName(domain.getAppurtenanceStatus());
        // 起点绝对距离(m)
        this.fromMileage = NumberFormat.format(domain.getFromMileage(), NumberFormat.FMT_PLACES3);
        // 起点相对最近参考点
        this.fromReference = domain.getFromReference();
        // 起点相对最近参考点距离(m)
        this.fromReferenceDistance = NumberFormat.format(domain.getFromReferenceDistance(), NumberFormat.FMT_PLACES3);
        // 终点绝对距离(m)
        this.toMileage = NumberFormat.format(domain.getToMileage(), NumberFormat.FMT_PLACES3);
        // 终点相对最近参考点
        this.toReference = domain.getToReference();
        // 终点相对最近参考点距离(m)
        this.toReferenceDistance = NumberFormat.format(domain.getToReferenceDistance(), NumberFormat.FMT_PLACES3);

        super.fromDomain(domain.getId(), domain.getRecorder(), domain.getRecordtime(), domain.getCreateRemark());
    }

    public void fromDomain(AdjunctPoint domain) {

        if (ObjectUtil.isEmptyAll(domain)) {
            return;
        }

        // 管道ID
        this.pipeLineName = PipeLineUtil.getPipeLineName(domain.getPipeLineId());
        // 统一编号
        this.code = domain.getCode();
        // 附属物编号(自定义编号)
        this.customNumber = domain.getCustomNumber();
        // 附属物类型
        this.appurtenanceType = CodeUtil.getName(domain.getAppurtenanceType());
        // 起点绝对距离(m)
        this.fromMileage = NumberFormat.format(domain.getMileage(), NumberFormat.FMT_PLACES3);
        // 起点相对最近参考点
        this.fromReference = domain.getReference();
        // 起点相对最近参考点距离(m)
        this.fromReferenceDistance = NumberFormat.format(domain.getReferenceDistance(), NumberFormat.FMT_PLACES3);
        // 附属物状态
        this.appurtenanceStatus = CodeUtil.getName(domain.getAppurtenanceStatus());

        super.fromDomain(domain.getId(), domain.getRecorder(), domain.getRecordtime(), domain.getCreateRemark());
    }

    public Page<AdjunctVo> forDomainLine(Page<AdjunctLine> adjunctLineList) {
        Page<AdjunctVo> adjunctVoList = new Page<AdjunctVo>();
        for (AdjunctLine adjunctPoint : adjunctLineList) {
            AdjunctVo adjunctVo = new AdjunctVo();
            adjunctVo.fromDomain(adjunctPoint);
            adjunctVoList.add(adjunctVo);
        }
        BaseVOUtil.converterPage(adjunctLineList, adjunctVoList);
        return adjunctVoList;
    }

    public Page<AdjunctVo> forDomainPoint(Page<AdjunctPoint> adjunctPointList) {
        Page<AdjunctVo> adjunctVoList = new Page<AdjunctVo>();
        for (AdjunctPoint adjunctPoint : adjunctPointList) {
            AdjunctVo adjunctVo = new AdjunctVo();
            adjunctVo.fromDomain(adjunctPoint);
            adjunctVoList.add(adjunctVo);
        }
        BaseVOUtil.converterPage(adjunctPointList, adjunctVoList);
        return adjunctVoList;
    }
}
